home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / grndfest.zip / ITEMS.QC < prev    next >
Text File  |  1996-09-17  |  28KB  |  1,304 lines

  1. void() W_SetCurrentAmmo;
  2. /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
  3. BE .8 .3 .4 IN COLOR */
  4.  
  5.  
  6. void() SUB_regen =
  7. {
  8.     self.model = self.mdl;        // restore original model
  9.     self.solid = SOLID_TRIGGER;    // allow it to be touched again
  10.     sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  11.     setorigin (self, self.origin);
  12. };
  13.  
  14.  
  15.  
  16. /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
  17. prints a warning message when spawned
  18. */
  19. void() noclass =
  20. {
  21.     dprint ("noclass spawned at");
  22.     dprint (vtos(self.origin));
  23.     dprint ("\n");
  24.     remove (self);
  25. };
  26.  
  27.  
  28.  
  29. /*
  30. ============
  31. PlaceItem
  32.  
  33. plants the object on the floor
  34. ============
  35. */
  36. void() PlaceItem =
  37. {
  38.     local float    oldz;
  39.  
  40.     self.mdl = self.model;        // so it can be restored on respawn
  41.     self.flags = FL_ITEM;        // make extra wide
  42.     self.solid = SOLID_TRIGGER;
  43.     self.movetype = MOVETYPE_TOSS;    
  44.     self.velocity = '0 0 0';
  45.     self.origin_z = self.origin_z + 6;
  46.     oldz = self.origin_z;
  47.     if (!droptofloor())
  48.     {
  49.         dprint ("Bonus item fell out of level at ");
  50.         dprint (vtos(self.origin));
  51.         dprint ("\n");
  52.         remove(self);
  53.         return;
  54.     }
  55. };
  56.  
  57. /*
  58. ============
  59. StartItem
  60.  
  61. Sets the clipping size and plants the object on the floor
  62. ============
  63. */
  64. void() StartItem =
  65. {
  66.     self.nextthink = time + 0.2;    // items start after other solids
  67.     self.think = PlaceItem;
  68. };
  69.  
  70. /*
  71. =========================================================================
  72.  
  73. HEALTH BOX
  74.  
  75. =========================================================================
  76. */
  77. //
  78. // T_Heal: add health to an entity, limiting health to max_health
  79. // "ignore" will ignore max_health limit
  80. //
  81. float (entity e, float healamount, float ignore) T_Heal =
  82. {
  83.     if (e.health <= 0)
  84.         return 0;
  85.     if ((!ignore) && (e.health >= other.max_health))
  86.         return 0;
  87.     healamount = ceil(healamount);
  88.  
  89.     e.health = e.health + healamount;
  90.     if ((!ignore) && (e.health >= other.max_health))
  91.         e.health = other.max_health;
  92.         
  93.     if (e.health > 250)
  94.         e.health = 250;
  95.     return 1;
  96. };
  97.  
  98. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  99. Health box. Normally gives 25 points.
  100. Rotten box heals 5-10 points,
  101. megahealth will add 100 health, then 
  102. rot you down to your maximum health limit, 
  103. one point per second.
  104. */
  105.  
  106. float    H_ROTTEN = 1;
  107. float    H_MEGA = 2;
  108. .float    healamount, healtype;
  109. void() health_touch;
  110. void() item_megahealth_rot;
  111.  
  112. void() item_health =
  113. {    
  114.     self.touch = health_touch;
  115.  
  116.     if (self.spawnflags & H_ROTTEN)
  117.     {
  118.         precache_model("maps/b_bh10.bsp");
  119.  
  120.         precache_sound("items/r_item1.wav");
  121.         setmodel(self, "maps/b_bh10.bsp");
  122.         self.noise = "items/r_item1.wav";
  123.         self.healamount = 15;
  124.         self.healtype = 0;
  125.     }
  126.     else
  127.     if (self.spawnflags & H_MEGA)
  128.     {
  129.         precache_model("maps/b_bh100.bsp");
  130.         precache_sound("items/r_item2.wav");
  131.         setmodel(self, "maps/b_bh100.bsp");
  132.         self.noise = "items/r_item2.wav";
  133.         self.healamount = 100;
  134.         self.healtype = 2;
  135.     }
  136.     else
  137.     {
  138.         precache_model("maps/b_bh25.bsp");
  139.         precache_sound("items/health1.wav");
  140.         setmodel(self, "maps/b_bh25.bsp");
  141.         self.noise = "items/health1.wav";
  142.         self.healamount = 25;
  143.         self.healtype = 1;
  144.     }
  145.     setsize (self, '0 0 0', '32 32 56');
  146.     StartItem ();
  147. };
  148.  
  149.  
  150. void() health_touch =
  151. {
  152.     local    float amount;
  153.     local    string    s;
  154.     
  155.     if (other.classname != "player")
  156.         return;
  157.     
  158.     if (self.healtype == 2) // Megahealth?  Ignore max_health...
  159.     {
  160.         if (other.health >= 250)
  161.             return;
  162.         if (!T_Heal(other, self.healamount, 1))
  163.             return;
  164.     }
  165.     else
  166.     {
  167.         if (!T_Heal(other, self.healamount, 0))
  168.             return;
  169.     }
  170.     
  171.     sprint(other, "You receive ");
  172.     s = ftos(self.healamount);
  173.     sprint(other, s);
  174.     sprint(other, " health\n");
  175.     
  176. // health touch sound
  177.     sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  178.  
  179.     stuffcmd (other, "bf\n");
  180.     
  181.     self.model = string_null;
  182.     self.solid = SOLID_NOT;
  183.  
  184.     // Megahealth = rot down the player's super health
  185.     if (self.healtype == 2)
  186.     {
  187.         other.items = other.items | IT_SUPERHEALTH;
  188.         self.nextthink = time + 5;
  189.         self.think = item_megahealth_rot;
  190.         self.owner = other;
  191.     }
  192.     else
  193.     {
  194.         if (deathmatch != 2)        // deathmatch 2 is the silly old rules
  195.         {
  196.             if (deathmatch)
  197.                 self.nextthink = time + 20;
  198.             self.think = SUB_regen;
  199.         }
  200.     }
  201.     
  202.     activator = other;
  203.     SUB_UseTargets();                // fire all targets / killtargets
  204. };    
  205.  
  206. void() item_megahealth_rot =
  207. {
  208.     other = self.owner;
  209.     
  210.     if (other.health > other.max_health)
  211.     {
  212.         other.health = other.health - 1;
  213.         self.nextthink = time + 1;
  214.         return;
  215.     }
  216.  
  217. // it is possible for a player to die and respawn between rots, so don't
  218. // just blindly subtract the flag off
  219.     other.items = other.items - (other.items & IT_SUPERHEALTH);
  220.     
  221.     if (deathmatch == 1)    // deathmatch 2 is silly old rules
  222.     {
  223.         self.nextthink = time + 20;
  224.         self.think = SUB_regen;
  225.     }
  226. };
  227.  
  228. /*
  229. ===============================================================================
  230.  
  231. ARMOR
  232.  
  233. ===============================================================================
  234. */
  235.  
  236. void() armor_touch;
  237.  
  238. void() armor_touch =
  239. {
  240.     local    float    type, value, bit;
  241.     
  242.     if (other.health <= 0)
  243.         return;
  244.     if (other.classname != "player")
  245.         return;
  246.  
  247.     if (self.classname == "item_armor1")
  248.     {
  249.         type = 0.3;
  250.         value = 100;
  251.         bit = IT_ARMOR1;
  252.     }
  253.     if (self.classname == "item_armor2")
  254.     {
  255.         type = 0.6;
  256.         value = 150;
  257.         bit = IT_ARMOR2;
  258.     }
  259.     if (self.classname == "item_armorInv")
  260.     {
  261.         type = 0.8;
  262.         value = 200;
  263.         bit = IT_ARMOR3;
  264.     }
  265.     if (other.armortype*other.armorvalue >= type*value)
  266.         return;
  267.         
  268.     other.armortype = type;
  269.     other.armorvalue = value;
  270.     other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
  271.  
  272.     self.solid = SOLID_NOT;
  273.     self.model = string_null;
  274.     if (deathmatch == 1)
  275.         self.nextthink = time + 20;
  276.     self.think = SUB_regen;
  277.  
  278.     sprint(other, "You got armor\n");
  279. // armor touch sound
  280.     sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  281.     stuffcmd (other, "bf\n");
  282.     
  283.     activator = other;
  284.     SUB_UseTargets();                // fire all targets / killtargets
  285. };
  286.  
  287.  
  288. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  289. */
  290.  
  291. void() item_armor1 =
  292. {
  293.     self.touch = armor_touch;
  294.     precache_model ("progs/armor.mdl");
  295.     setmodel (self, "progs/armor.mdl");
  296.     self.skin = 0;
  297.     setsize (self, '-16 -16 0', '16 16 56');
  298.     StartItem ();
  299. };
  300.  
  301. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  302. */
  303.  
  304. void() item_armor2 =
  305. {
  306.     self.touch = armor_touch;
  307.     precache_model ("progs/armor.mdl");
  308.     setmodel (self, "progs/armor.mdl");
  309.     self.skin = 1;
  310.     setsize (self, '-16 -16 0', '16 16 56');
  311.     StartItem ();
  312. };
  313.  
  314. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  315. */
  316.  
  317. void() item_armorInv =
  318. {
  319.     self.touch = armor_touch;
  320.     precache_model ("progs/armor.mdl");
  321.     setmodel (self, "progs/armor.mdl");
  322.     self.skin = 2;
  323.     setsize (self, '-16 -16 0', '16 16 56');
  324.     StartItem ();
  325. };
  326.  
  327. /*
  328. ===============================================================================
  329.  
  330. WEAPONS
  331.  
  332. ===============================================================================
  333. */
  334.  
  335. void() bound_other_ammo =
  336. {
  337.     if (other.ammo_shells > 100)
  338.         other.ammo_shells = 100;
  339.     if (other.ammo_nails > 200)
  340.         other.ammo_nails = 200;
  341.     if (other.ammo_rockets > 100)
  342.         other.ammo_rockets = 100;        
  343.     if (other.ammo_cells > 100)
  344.         other.ammo_cells = 100;        
  345. };
  346.  
  347.  
  348. float(float w) RankForWeapon =
  349. {
  350.     if (w == IT_LIGHTNING)
  351.         return 1;
  352.     if (w == IT_ROCKET_LAUNCHER)
  353.         return 2;
  354.     if (w == IT_SUPER_NAILGUN)
  355.         return 3;
  356.     if (w == IT_GRENADE_LAUNCHER)
  357.         return 4;
  358.     if (w == IT_SUPER_SHOTGUN)
  359.         return 5;
  360.     if (w == IT_NAILGUN)
  361.         return 6;
  362.     return 7;
  363. };
  364.  
  365. /*
  366. =============
  367. Deathmatch_Weapon
  368.  
  369. Deathmatch weapon change rules for picking up a weapon
  370.  
  371. .float        ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  372. =============
  373. */
  374. void(float old, float new) Deathmatch_Weapon =
  375. {
  376.     local float or, nr;
  377.  
  378. // change self.weapon if desired
  379.     or = RankForWeapon (self.weapon);
  380.     nr = RankForWeapon (new);
  381.     if ( nr < or )
  382.         self.weapon = new;
  383. };
  384.  
  385. /*
  386. =============
  387. weapon_touch
  388. =============
  389. */
  390. float() W_BestWeapon;
  391.  
  392. void() weapon_touch =
  393. {
  394.     local    float    hadammo, best, new, old;
  395.     local    entity    stemp;
  396.     local    float    leave;
  397.  
  398.     if (!(other.flags & FL_CLIENT))
  399.         return;
  400.  
  401.    self.classname = "weapon_grenadelauncher";
  402.  
  403. // if the player was using his best weapon, change up to the new one if better
  404.     stemp = self;
  405.     self = other;
  406.     best = W_BestWeapon();
  407.     self = stemp;
  408.  
  409.     if (deathmatch == 2 || coop)
  410.         leave = 1;
  411.     else
  412.         leave = 0;
  413.     
  414.    if (self.classname == "weapon_grenadelauncher")
  415.     {
  416.         if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  417.             return;
  418.         hadammo = other.ammo_rockets;            
  419.         new = IT_GRENADE_LAUNCHER;
  420.         other.ammo_rockets = other.ammo_rockets + 5;
  421.     }
  422.     else
  423.         objerror ("weapon_touch: unknown classname");
  424.  
  425.     sprint (other, "You got the ");
  426.     sprint (other, self.netname);
  427.     sprint (other, "\n");
  428. // weapon touch sound
  429.     sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  430.     stuffcmd (other, "bf\n");
  431.  
  432.     bound_other_ammo ();
  433.  
  434. // change to the weapon
  435.     old = other.items;
  436.     other.items = other.items | new;
  437.     
  438.     stemp = self;
  439.     self = other;
  440.  
  441.     if (!deathmatch)
  442.         self.weapon = new;
  443.     else
  444.         Deathmatch_Weapon (old, new);
  445.  
  446.     W_SetCurrentAmmo();
  447.  
  448.     self = stemp;
  449.  
  450.     if (leave)
  451.         return;
  452.  
  453. // remove it in single player, or setup for respawning in deathmatch
  454.     self.model = string_null;
  455.     self.solid = SOLID_NOT;
  456.     if (deathmatch == 1)
  457.         self.nextthink = time + 30;
  458.     self.think = SUB_regen;
  459.     
  460.     activator = other;
  461.     SUB_UseTargets();                // fire all targets / killtargets
  462. };
  463.  
  464.  
  465. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  466. */
  467.  
  468. void() weapon_supershotgun =
  469. {
  470.     precache_model ("progs/g_rock.mdl");
  471.     setmodel (self, "progs/g_rock.mdl");
  472.     self.weapon = 3;
  473.     self.netname = "Grenade Launcher";
  474.     self.touch = weapon_touch;
  475.     setsize (self, '-16 -16 0', '16 16 56');
  476.     StartItem ();
  477. };
  478.  
  479. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  480. */
  481.  
  482. void() weapon_nailgun =
  483. {
  484.     precache_model ("progs/g_rock.mdl");
  485.     setmodel (self, "progs/g_rock.mdl");
  486.     self.weapon = 3;
  487.     self.netname = "Grenade Launcher";
  488.     self.touch = weapon_touch;
  489.     setsize (self, '-16 -16 0', '16 16 56');
  490.     StartItem ();
  491. };
  492.  
  493. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  494. */
  495.  
  496. void() weapon_supernailgun =
  497. {
  498.     precache_model ("progs/g_rock.mdl");
  499.     setmodel (self, "progs/g_rock.mdl");
  500.     self.weapon = 3;
  501.     self.netname = "Grenade Launcher";
  502.     self.touch = weapon_touch;
  503.     setsize (self, '-16 -16 0', '16 16 56');
  504.     StartItem ();
  505. };
  506.  
  507. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  508. */
  509.  
  510. void() weapon_grenadelauncher =
  511. {
  512.     precache_model ("progs/g_rock.mdl");
  513.     setmodel (self, "progs/g_rock.mdl");
  514.     self.weapon = 3;
  515.     self.netname = "Grenade Launcher";
  516.     self.touch = weapon_touch;
  517.     setsize (self, '-16 -16 0', '16 16 56');
  518.     StartItem ();
  519. };
  520.  
  521. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  522. */
  523.  
  524. void() weapon_rocketlauncher =
  525. {
  526.     precache_model ("progs/g_rock.mdl");
  527.     setmodel (self, "progs/g_rock.mdl");
  528.     self.weapon = 3;
  529.     self.netname = "Grenade Launcher";
  530.     self.touch = weapon_touch;
  531.     setsize (self, '-16 -16 0', '16 16 56');
  532.     StartItem ();
  533. };
  534.  
  535.  
  536. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  537. */
  538.  
  539. void() weapon_lightning =
  540. {
  541.     precache_model ("progs/g_rock.mdl");
  542.     setmodel (self, "progs/g_rock.mdl");
  543.     self.weapon = 3;
  544.     self.netname = "Grenade Launcher";
  545.     self.touch = weapon_touch;
  546.     setsize (self, '-16 -16 0', '16 16 56');
  547.     StartItem ();
  548. };
  549.  
  550.  
  551. /*
  552. ===============================================================================
  553.  
  554. AMMO
  555.  
  556. ===============================================================================
  557. */
  558.  
  559. void() ammo_touch =
  560. {
  561. local entity    stemp;
  562. local float        best;
  563.  
  564.     if (other.classname != "player")
  565.         return;
  566.     if (other.health <= 0)
  567.         return;
  568.  
  569. // if the player was using his best weapon, change up to the new one if better        
  570.     stemp = self;
  571.     self = other;
  572.     best = W_BestWeapon();
  573.     self = stemp;
  574.  
  575.  
  576. // shotgun
  577.     if (self.weapon == 1)
  578.     {
  579.         if (other.ammo_shells >= 100)
  580.             return;
  581.         other.ammo_shells = other.ammo_shells + self.aflag;
  582.     }
  583.  
  584. // spikes
  585.     if (self.weapon == 2)
  586.     {
  587.         if (other.ammo_nails >= 200)
  588.             return;
  589.         other.ammo_nails = other.ammo_nails + self.aflag;
  590.     }
  591.  
  592. //    rockets
  593.     if (self.weapon == 3)
  594.     {
  595.         if (other.ammo_rockets >= 100)
  596.             return;
  597.         other.ammo_rockets = other.ammo_rockets + self.aflag;
  598.     }
  599.  
  600. //    cells
  601.     if (self.weapon == 4)
  602.     {
  603.         if (other.ammo_cells >= 200)
  604.             return;
  605.         other.ammo_cells = other.ammo_cells + self.aflag;
  606.     }
  607.  
  608.     bound_other_ammo ();
  609.     
  610.     sprint (other, "You got the ");
  611.     sprint (other, self.netname);
  612.     sprint (other, "\n");
  613. // ammo touch sound
  614.     sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  615.     stuffcmd (other, "bf\n");
  616.  
  617. // change to a better weapon if appropriate
  618.  
  619.     if ( other.weapon == best )
  620.     {
  621.         stemp = self;
  622.         self = other;
  623.         self.weapon = W_BestWeapon();
  624.         W_SetCurrentAmmo ();
  625.         self = stemp;
  626.     }
  627.  
  628. // if changed current ammo, update it
  629.     stemp = self;
  630.     self = other;
  631.     W_SetCurrentAmmo();
  632.     self = stemp;
  633.  
  634. // remove it in single player, or setup for respawning in deathmatch
  635.     self.model = string_null;
  636.     self.solid = SOLID_NOT;
  637.     if (deathmatch == 1)
  638.         self.nextthink = time + 30;
  639.     
  640.     self.think = SUB_regen;
  641.  
  642.     activator = other;
  643.     SUB_UseTargets();                // fire all targets / killtargets
  644. };
  645.  
  646.  
  647.  
  648.  
  649. float WEAPON_BIG2 = 1;
  650.  
  651. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  652. */
  653.  
  654. void() item_shells =
  655. {
  656.     self.touch = ammo_touch;
  657.  
  658.     if (self.spawnflags & WEAPON_BIG2)
  659.     {
  660.         precache_model ("maps/b_rock1.bsp");
  661.         setmodel (self, "maps/b_rock1.bsp");
  662.       self.aflag = 10;
  663.     }
  664.     else
  665.     {
  666.         precache_model ("maps/b_rock0.bsp");
  667.         setmodel (self, "maps/b_rock0.bsp");
  668.       self.aflag = 5;
  669.     }
  670.     self.weapon = 3;
  671.     self.netname = "rockets";
  672.     setsize (self, '0 0 0', '32 32 56');
  673.     StartItem ();
  674. };
  675.  
  676. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  677. */
  678.  
  679. void() item_spikes =
  680. {
  681.     self.touch = ammo_touch;
  682.  
  683.     if (self.spawnflags & WEAPON_BIG2)
  684.     {
  685.         precache_model ("maps/b_rock1.bsp");
  686.         setmodel (self, "maps/b_rock1.bsp");
  687.       self.aflag = 10;
  688.     }
  689.     else
  690.     {
  691.         precache_model ("maps/b_rock0.bsp");
  692.         setmodel (self, "maps/b_rock0.bsp");
  693.       self.aflag = 5;
  694.     }
  695.     self.weapon = 3;
  696.     self.netname = "rockets";
  697.     setsize (self, '0 0 0', '32 32 56');
  698.     StartItem ();
  699. };
  700.  
  701. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  702. */
  703.  
  704. void() item_rockets =
  705. {
  706.     self.touch = ammo_touch;
  707.  
  708.     if (self.spawnflags & WEAPON_BIG2)
  709.     {
  710.         precache_model ("maps/b_rock1.bsp");
  711.         setmodel (self, "maps/b_rock1.bsp");
  712.       self.aflag = 10;
  713.     }
  714.     else
  715.     {
  716.         precache_model ("maps/b_rock0.bsp");
  717.         setmodel (self, "maps/b_rock0.bsp");
  718.       self.aflag = 5;
  719.     }
  720.     self.weapon = 3;
  721.     self.netname = "rockets";
  722.     setsize (self, '0 0 0', '32 32 56');
  723.     StartItem ();
  724. };
  725.  
  726.  
  727. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  728. */
  729.  
  730. void() item_cells =
  731. {
  732.     self.touch = ammo_touch;
  733.  
  734.     if (self.spawnflags & WEAPON_BIG2)
  735.     {
  736.         precache_model ("maps/b_rock1.bsp");
  737.         setmodel (self, "maps/b_rock1.bsp");
  738.       self.aflag = 10;
  739.     }
  740.     else
  741.     {
  742.         precache_model ("maps/b_rock0.bsp");
  743.         setmodel (self, "maps/b_rock0.bsp");
  744.       self.aflag = 5;
  745.     }
  746.     self.weapon = 3;
  747.     self.netname = "rockets";
  748.     setsize (self, '0 0 0', '32 32 56');
  749.     StartItem ();
  750. };
  751.  
  752.  
  753. /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
  754. DO NOT USE THIS!!!! IT WILL BE REMOVED!
  755. */
  756.  
  757. float WEAPON_SHOTGUN = 1;
  758. float WEAPON_ROCKET = 2;
  759. float WEAPON_SPIKES = 4;
  760. float WEAPON_BIG = 8;
  761. void() item_weapon =
  762. {
  763.     self.touch = ammo_touch;
  764.  
  765.     if (self.spawnflags & WEAPON_SHOTGUN)
  766.     {
  767.         if (self.spawnflags & WEAPON_BIG)
  768.         {
  769.             precache_model ("maps/b_rock1.bsp");
  770.             setmodel (self, "maps/b_rock1.bsp");
  771.             self.aflag = 10;
  772.         }
  773.         else
  774.         {
  775.             precache_model ("maps/b_rock0.bsp");
  776.             setmodel (self, "maps/b_rock0.bsp");
  777.             self.aflag = 5;
  778.         }
  779.         self.weapon = 3;
  780.         self.netname = "rockets";
  781.     }
  782.  
  783.     if (self.spawnflags & WEAPON_SPIKES)
  784.     {
  785.         if (self.spawnflags & WEAPON_BIG)
  786.         {
  787.             precache_model ("maps/b_rock1.bsp");
  788.             setmodel (self, "maps/b_rock1.bsp");
  789.             self.aflag = 10;
  790.         }
  791.         else
  792.         {
  793.             precache_model ("maps/b_rock0.bsp");
  794.             setmodel (self, "maps/b_rock0.bsp");
  795.             self.aflag = 5;
  796.         }
  797.         self.weapon = 3;
  798.         self.netname = "rockets";
  799.     }
  800.  
  801.     if (self.spawnflags & WEAPON_ROCKET)
  802.     {
  803.         if (self.spawnflags & WEAPON_BIG)
  804.         {
  805.             precache_model ("maps/b_rock1.bsp");
  806.             setmodel (self, "maps/b_rock1.bsp");
  807.             self.aflag = 10;
  808.         }
  809.         else
  810.         {
  811.             precache_model ("maps/b_rock0.bsp");
  812.             setmodel (self, "maps/b_rock0.bsp");
  813.             self.aflag = 5;
  814.         }
  815.         self.weapon = 3;
  816.         self.netname = "rockets";
  817.     }
  818.     
  819.     setsize (self, '0 0 0', '32 32 56');
  820.     StartItem ();
  821. };
  822.  
  823.  
  824. /*
  825. ===============================================================================
  826.  
  827. KEYS
  828.  
  829. ===============================================================================
  830. */
  831.  
  832. void() key_touch =
  833. {
  834. local entity    stemp;
  835. local float        best;
  836.  
  837.     if (other.classname != "player")
  838.         return;
  839.     if (other.health <= 0)
  840.         return;
  841.     if (other.items & self.items)
  842.         return;
  843.  
  844.     sprint (other, "You got the ");
  845.     sprint (other, self.netname);
  846.     sprint (other,"\n");
  847.  
  848.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  849.     stuffcmd (other, "bf\n");
  850.     other.items = other.items | self.items;
  851.  
  852.     if (!coop)
  853.     {    
  854.         self.solid = SOLID_NOT;
  855.         self.model = string_null;
  856.     }
  857.  
  858.     activator = other;
  859.     SUB_UseTargets();                // fire all targets / killtargets
  860. };
  861.  
  862.  
  863. void() key_setsounds =
  864. {
  865.     if (world.worldtype == 0)
  866.     {
  867.         precache_sound ("misc/medkey.wav");
  868.         self.noise = "misc/medkey.wav";
  869.     }
  870.     if (world.worldtype == 1)
  871.     {
  872.         precache_sound ("misc/runekey.wav");
  873.         self.noise = "misc/runekey.wav";
  874.     }
  875.     if (world.worldtype == 2)
  876.     {
  877.         precache_sound2 ("misc/basekey.wav");
  878.         self.noise = "misc/basekey.wav";
  879.     }
  880. };
  881.  
  882. /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
  883. SILVER key
  884. In order for keys to work
  885. you MUST set your maps
  886. worldtype to one of the
  887. following:
  888. 0: medieval
  889. 1: metal
  890. 2: base
  891. */
  892.  
  893. void() item_key1 =
  894. {
  895.     if (world.worldtype == 0)
  896.     {
  897.         precache_model ("progs/w_s_key.mdl");
  898.         setmodel (self, "progs/w_s_key.mdl");
  899.         self.netname = "silver key";
  900.     }
  901.     else if (world.worldtype == 1)
  902.     {
  903.         precache_model ("progs/m_s_key.mdl");
  904.         setmodel (self, "progs/m_s_key.mdl");
  905.         self.netname = "silver runekey";
  906.     }
  907.     else if (world.worldtype == 2)
  908.     {
  909.         precache_model2 ("progs/b_s_key.mdl");
  910.         setmodel (self, "progs/b_s_key.mdl");
  911.         self.netname = "silver keycard";
  912.     }
  913.     key_setsounds();
  914.     self.touch = key_touch;
  915.     self.items = IT_KEY1;
  916.     setsize (self, '-16 -16 -24', '16 16 32');
  917.     StartItem ();
  918. };
  919.  
  920. /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
  921. GOLD key
  922. In order for keys to work
  923. you MUST set your maps
  924. worldtype to one of the
  925. following:
  926. 0: medieval
  927. 1: metal
  928. 2: base
  929. */
  930.  
  931. void() item_key2 =
  932. {
  933.     if (world.worldtype == 0)
  934.     {
  935.         precache_model ("progs/w_g_key.mdl");
  936.         setmodel (self, "progs/w_g_key.mdl");
  937.         self.netname = "gold key";
  938.     }
  939.     if (world.worldtype == 1)
  940.     {
  941.         precache_model ("progs/m_g_key.mdl");
  942.         setmodel (self, "progs/m_g_key.mdl");
  943.         self.netname = "gold runekey";
  944.     }
  945.     if (world.worldtype == 2)
  946.     {
  947.         precache_model2 ("progs/b_g_key.mdl");
  948.         setmodel (self, "progs/b_g_key.mdl");
  949.         self.netname = "gold keycard";
  950.     }
  951.     key_setsounds();
  952.     self.touch = key_touch;
  953.     self.items = IT_KEY2;
  954.     setsize (self, '-16 -16 -24', '16 16 32');
  955.     StartItem ();
  956. };
  957.  
  958.  
  959.  
  960. /*
  961. ===============================================================================
  962.  
  963. END OF LEVEL RUNES
  964.  
  965. ===============================================================================
  966. */
  967.  
  968. void() sigil_touch =
  969. {
  970. local entity    stemp;
  971. local float        best;
  972.  
  973.     if (other.classname != "player")
  974.         return;
  975.     if (other.health <= 0)
  976.         return;
  977.  
  978.     centerprint (other, "You got the rune!");
  979.  
  980.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  981.     stuffcmd (other, "bf\n");
  982.     self.solid = SOLID_NOT;
  983.     self.model = string_null;
  984.     serverflags = serverflags | (self.spawnflags & 15);
  985.     self.classname = "";        // so rune doors won't find it
  986.     
  987.     activator = other;
  988.     SUB_UseTargets();                // fire all targets / killtargets
  989. };
  990.  
  991.  
  992. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
  993. End of level sigil, pick up to end episode and return to jrstart.
  994. */
  995.  
  996. void() item_sigil =
  997. {
  998.     if (!self.spawnflags)
  999.         objerror ("no spawnflags");
  1000.  
  1001.     precache_sound ("misc/runekey.wav");
  1002.     self.noise = "misc/runekey.wav";
  1003.  
  1004.     if (self.spawnflags & 1)
  1005.     {
  1006.         precache_model ("progs/end1.mdl");
  1007.         setmodel (self, "progs/end1.mdl");
  1008.     }
  1009.     if (self.spawnflags & 2)
  1010.     {
  1011.         precache_model2 ("progs/end2.mdl");
  1012.         setmodel (self, "progs/end2.mdl");
  1013.     }
  1014.     if (self.spawnflags & 4)
  1015.     {
  1016.         precache_model2 ("progs/end3.mdl");
  1017.         setmodel (self, "progs/end3.mdl");
  1018.     }
  1019.     if (self.spawnflags & 8)
  1020.     {
  1021.         precache_model2 ("progs/end4.mdl");
  1022.         setmodel (self, "progs/end4.mdl");
  1023.     }
  1024.     
  1025.     self.touch = sigil_touch;
  1026.     setsize (self, '-16 -16 -24', '16 16 32');
  1027.     StartItem ();
  1028. };
  1029.  
  1030. /*
  1031. ===============================================================================
  1032.  
  1033. POWERUPS
  1034.  
  1035. ===============================================================================
  1036. */
  1037.  
  1038. void() powerup_touch;
  1039.  
  1040.  
  1041. void() powerup_touch =
  1042. {
  1043. local entity    stemp;
  1044. local float        best;
  1045.  
  1046.     if (other.classname != "player")
  1047.         return;
  1048.     if (other.health <= 0)
  1049.         return;
  1050.  
  1051.     sprint (other, "You got the ");
  1052.     sprint (other, self.netname);
  1053.     sprint (other,"\n");
  1054.  
  1055.     if (deathmatch)
  1056.     {
  1057.         self.mdl = self.model;
  1058.         
  1059.         if ((self.classname == "item_artifact_invulnerability") ||
  1060.             (self.classname == "item_artifact_invisibility"))
  1061.             self.nextthink = time + 60*5;
  1062.         else
  1063.             self.nextthink = time + 60;
  1064.         
  1065.         self.think = SUB_regen;
  1066.     }    
  1067.  
  1068.     sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  1069.     stuffcmd (other, "bf\n");
  1070.     self.solid = SOLID_NOT;
  1071.     other.items = other.items | self.items;
  1072.     self.model = string_null;
  1073.  
  1074. // do the apropriate action
  1075.     if (self.classname == "item_artifact_envirosuit")
  1076.     {
  1077.         other.rad_time = 1;
  1078.         other.radsuit_finished = time + 30;
  1079.     }
  1080.     
  1081.     if (self.classname == "item_artifact_invulnerability")
  1082.     {
  1083.         other.invincible_time = 1;
  1084.         other.invincible_finished = time + 30;
  1085.     }
  1086.     
  1087.     if (self.classname == "item_artifact_invisibility")
  1088.     {
  1089.         other.invisible_time = 1;
  1090.         other.invisible_finished = time + 30;
  1091.     }
  1092.  
  1093.     if (self.classname == "item_artifact_super_damage")
  1094.     {
  1095.         other.super_time = 1;
  1096.         other.super_damage_finished = time + 30;
  1097.     }    
  1098.  
  1099.     activator = other;
  1100.     SUB_UseTargets();                // fire all targets / killtargets
  1101. };
  1102.  
  1103.  
  1104.  
  1105. /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
  1106. Player is invulnerable for 30 seconds
  1107. */
  1108. void() item_artifact_invulnerability =
  1109. {
  1110.     self.touch = powerup_touch;
  1111.  
  1112.     precache_model ("progs/invulner.mdl");
  1113.     precache_sound ("items/protect.wav");
  1114.     precache_sound ("items/protect2.wav");
  1115.     precache_sound ("items/protect3.wav");
  1116.     self.noise = "items/protect.wav";
  1117.     setmodel (self, "progs/invulner.mdl");
  1118.     self.netname = "Pentagram of Protection";
  1119.     self.items = IT_INVULNERABILITY;
  1120.     setsize (self, '-16 -16 -24', '16 16 32');
  1121.     StartItem ();
  1122. };
  1123.  
  1124. /*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
  1125. Player takes no damage from water or slime for 30 seconds
  1126. */
  1127. void() item_artifact_envirosuit =
  1128. {
  1129.     self.touch = powerup_touch;
  1130.  
  1131.     precache_model ("progs/suit.mdl");
  1132.     precache_sound ("items/suit.wav");
  1133.     precache_sound ("items/suit2.wav");
  1134.     self.noise = "items/suit.wav";
  1135.     setmodel (self, "progs/suit.mdl");
  1136.     self.netname = "Biosuit";
  1137.     self.items = IT_SUIT;
  1138.     setsize (self, '-16 -16 -24', '16 16 32');
  1139.     StartItem ();
  1140. };
  1141.  
  1142.  
  1143. /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
  1144. Player is invisible for 30 seconds
  1145. */
  1146. void() item_artifact_invisibility =
  1147. {
  1148.     self.touch = powerup_touch;
  1149.  
  1150.     precache_model ("progs/invisibl.mdl");
  1151.     precache_sound ("items/inv1.wav");
  1152.     precache_sound ("items/inv2.wav");
  1153.     precache_sound ("items/inv3.wav");
  1154.     self.noise = "items/inv1.wav";
  1155.     setmodel (self, "progs/invisibl.mdl");
  1156.     self.netname = "Ring of Shadows";
  1157.     self.items = IT_INVISIBILITY;
  1158.     setsize (self, '-16 -16 -24', '16 16 32');
  1159.     StartItem ();
  1160. };
  1161.  
  1162.  
  1163. /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
  1164. The next attack from the player will do 4x damage
  1165. */
  1166. void() item_artifact_super_damage =
  1167. {
  1168.     self.touch = powerup_touch;
  1169.  
  1170.     precache_model ("progs/quaddama.mdl");
  1171.     precache_sound ("items/damage.wav");
  1172.     precache_sound ("items/damage2.wav");
  1173.     precache_sound ("items/damage3.wav");
  1174.     self.noise = "items/damage.wav";
  1175.     setmodel (self, "progs/quaddama.mdl");
  1176.     self.netname = "Quad Damage";
  1177.     self.items = IT_QUAD;
  1178.     setsize (self, '-16 -16 -24', '16 16 32');
  1179.     StartItem ();
  1180. };
  1181.  
  1182.  
  1183.  
  1184. /*
  1185. ===============================================================================
  1186.  
  1187. PLAYER BACKPACKS
  1188.  
  1189. ===============================================================================
  1190. */
  1191.  
  1192. void() BackpackTouch =
  1193. {
  1194.     local string    s;
  1195.     local    float    best;
  1196.     local        entity    stemp;
  1197.     
  1198.     if (other.classname != "player")
  1199.         return;
  1200.     if (other.health <= 0)
  1201.         return;
  1202.         
  1203. // if the player was using his best weapon, change up to the new one if better        
  1204.     stemp = self;
  1205.     self = other;
  1206.     best = W_BestWeapon();
  1207.     self = stemp;
  1208.  
  1209. // change weapons
  1210.     other.ammo_shells = other.ammo_shells + self.ammo_shells;
  1211.     other.ammo_nails = other.ammo_nails + self.ammo_nails;
  1212.     other.ammo_rockets = other.ammo_rockets + self.ammo_rockets;
  1213.     other.ammo_cells = other.ammo_cells + self.ammo_cells;
  1214.  
  1215.     other.items = other.items | self.items;
  1216.     
  1217.     bound_other_ammo ();
  1218.  
  1219.     sprint (other, "You get ");
  1220.  
  1221.     if (self.ammo_shells)
  1222.     {
  1223.         s = ftos(self.ammo_shells);
  1224.         sprint (other, s);
  1225.         sprint (other, " shells  ");
  1226.     }
  1227.     if (self.ammo_nails)
  1228.     {
  1229.         s = ftos(self.ammo_nails);
  1230.         sprint (other, s);
  1231.         sprint (other, " nails ");
  1232.     }
  1233.     if (self.ammo_rockets)
  1234.     {
  1235.         s = ftos(self.ammo_rockets);
  1236.         sprint (other, s);
  1237.         sprint (other, " rockets  ");
  1238.     }
  1239.     if (self.ammo_cells)
  1240.     {
  1241.         s = ftos(self.ammo_cells);
  1242.         sprint (other, s);
  1243.         sprint (other, " cells  ");
  1244.     }
  1245.     
  1246.     sprint (other, "\n");
  1247. // backpack touch sound
  1248.     sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  1249.     stuffcmd (other, "bf\n");
  1250.  
  1251. // change to a better weapon if appropriate
  1252.     if ( other.weapon == best )
  1253.     {
  1254.         stemp = self;
  1255.         self = other;
  1256.         self.weapon = W_BestWeapon();
  1257.         self = stemp;
  1258.     }
  1259.  
  1260.     
  1261.     remove(self);
  1262.     
  1263.     self = other;
  1264.     W_SetCurrentAmmo ();
  1265. };
  1266.  
  1267. /*
  1268. ===============
  1269. DropBackpack
  1270. ===============
  1271. */
  1272. void() DropBackpack =
  1273. {
  1274.     local entity    item;
  1275.  
  1276.     if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells))
  1277.         return;    // nothing in it
  1278.  
  1279.     item = spawn();
  1280.     item.origin = self.origin - '0 0 24';
  1281.     
  1282.     item.items = self.weapon;
  1283.  
  1284.    item.ammo_shells = 0; // self.ammo_shells;
  1285.    item.ammo_nails = 0; // self.ammo_nails;
  1286.    item.ammo_cells = 0; // self.ammo_cells;
  1287.  
  1288.    item.ammo_rockets = 2;
  1289.  
  1290.     item.velocity_z = 300;
  1291.     item.velocity_x = -100 + (random() * 200);
  1292.     item.velocity_y = -100 + (random() * 200);
  1293.     
  1294.     item.flags = FL_ITEM;
  1295.     item.solid = SOLID_TRIGGER;
  1296.     item.movetype = MOVETYPE_TOSS;
  1297.     setmodel (item, "progs/backpack.mdl");
  1298.     setsize (item, '-16 -16 0', '16 16 56');
  1299.     item.touch = BackpackTouch;
  1300.     
  1301.     item.nextthink = time + 120;    // remove after 2 minutes
  1302.     item.think = SUB_Remove;
  1303. };
  1304.